package ecoiot.com.testproject.chart;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.view.MotionEvent;

import lecho.lib.hellocharts.model.LineChartData;
import lecho.lib.hellocharts.view.LineChartView;

/**
 * Created by developer on 17-8-3.
 */

public class DemoLineChartView extends LineChartView {

    private Paint paint;

    private long touchTime = 0;

    private LineChartData lineData = null;


    public DemoLineChartView(Context context) {
        super(context);
    }

    public DemoLineChartView(Context context, AttributeSet attrs) {
        super(context, attrs);
        paint = new Paint();
        paint.setColor(Color.BLACK);
        paint.setStrokeWidth(1);
    }

    /**
     * 屏蔽双击缩放功能
     * @param event
     * @return
     */
    @Override
    public boolean onTouchEvent(MotionEvent event) {
        if (event.getAction() == MotionEvent.ACTION_DOWN) {
            long currentTime = System.currentTimeMillis();
            if (currentTime - touchTime > 500) {
                // 第一次按下 或者 两次按下的间隔时间较长 表示不是双击事件837914018 413995234
                touchTime = currentTime;
                return super.onTouchEvent(event);
            }else {
                // 两次按下间隔时间较短 表示是双击事件
                touchTime = currentTime;
                return true;
            }
        }
        return super.onTouchEvent(event);
    }

    @Override
    public void setLineChartData(LineChartData data) {

        super.setLineChartData(data);
    }

    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        super.onMeasure(widthMeasureSpec, heightMeasureSpec);
    }

    @Override
    protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
        super.onLayout(changed, left, top, right, bottom);

    }

    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);

    }
}
